import { ISchema } from '@formily/react'

export const DetailContainer: ISchema & { Item?: ISchema } = {
  type: 'object',
  properties: {
    title: {
      type: 'string',
      'x-decorator': 'FormItem',
      'x-component': 'Input',
      'x-component-props': {
        placeholder: '请输入标题',
      },
    },
    bordered: {
      type: 'boolean',
      'x-decorator': 'FormItem',
      'x-component': 'Switch',
      'x-component-props': {
        defaultChecked: false,
      },
    },
    column: {
      type: 'number',
      'x-decorator': 'FormItem',
      'x-component': 'NumberPicker',
      'x-component-props': {
        min: 1,
        max: 6,
        defaultValue: 3,
      },
    },
    size: {
      type: 'string',
      enum: ['default', 'middle', 'small'],
      'x-decorator': 'FormItem',
      'x-component': 'Select',
      'x-component-props': {
        defaultValue: 'default',
        options: [
          { label: '默认', value: 'default' },
          { label: '中等', value: 'middle' },
          { label: '小', value: 'small' },
        ],
      },
    },
    layout: {
      type: 'string',
      enum: ['horizontal', 'vertical'],
      'x-decorator': 'FormItem',
      'x-component': 'Select',
      'x-component-props': {
        defaultValue: 'horizontal',
        options: [
          { label: '水平', value: 'horizontal' },
          { label: '垂直', value: 'vertical' },
        ],
      },
    },
  },
}

DetailContainer.Item = {
  type: 'object',
  properties: {
    label: {
      type: 'string',
      'x-decorator': 'FormItem',
      'x-component': 'Input',
    },
    span: {
      type: 'number',
      'x-decorator': 'FormItem',
      'x-component': 'NumberPicker',
      'x-component-props': {
        min: 1,
        max: 6,
        defaultValue: 1,
      },
    },
    children: {
      type: 'string',
      'x-decorator': 'FormItem',
      'x-component': 'Input',
    },
    nameKey: {
      type: 'string',
      'x-decorator': 'FormItem',
      'x-component': 'Input.TextArea',
    },
    visibleExpression: {
      title: '显示表达式',
      type: 'string',
      'x-decorator': 'FormItem',
      'x-component': 'ExpressionDialogSetter',
    },
    onClickExpression: {
      title: '点击事件表达式',
      type: 'string',
      'x-decorator': 'FormItem',
      'x-component': 'ExpressionDialogSetter',
      'x-component-props': {
        placeholder: '请输入点击事件表达式，如：console.log("点击了")',
      },
    },
    desensitize: {
      title: '是否脱敏',
      type: 'boolean',
      'x-decorator': 'FormItem',
      'x-component': 'Switch',
      'x-component-props': {
        defaultChecked: false,
      },
    },
  },
}
